package net.oschina.app;

import android.util.Log;
import android.view.View;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;

import com.robotium.solo.By;
import com.robotium.solo.Solo;
import com.robotium.solo.WebElement;

import java.util.List;

/**
 * Created by Aaron on 2017/3/5.
 */

public class SoloWrap {
    private Solo solo;

    public SoloWrap(Solo solo){
        this.solo = solo;
    }

    public boolean waitForText(String text){
        return solo.waitForText(text,1,5000,false,true);
    }

    public void clickOnView(View view){
        solo.waitForView(view,1,5000,false);
        Log.i("AUTO","==============Click "+view.getId());
        solo.clickOnView(view);
    }

    public View getView(String id){
        try{
            return solo.getView(id);
        }catch (Exception ex){
            return null;
        }
    }

    public ImageButton getImageButton(int index){
       return  solo.getImageButton(index);
    }

    public void enterText(EditText et, String text){
        Log.i("AUTO","====================enter text "+ text);
        solo.enterText(et,text);
    }

    public void clearEditText(EditText et){
        Log.i("AUTO","====================clear text ");
        solo.clearEditText(et);
    }

    public List<View> getCurrentViews(Class cls){
        return solo.getCurrentViews(cls);
    }

    public void sleep(int seconds){
        solo.sleep(seconds * 1000);
    }

    public List<WebElement> getWebElements(By by){
        return solo.getWebElements(by);
    }
}
